﻿using Compass.Wasm.Shared.Categories;
using Compass.Wasm.Shared.Plans;
using Compass.Wasm.Shared.Wms;
using Zack.DomainCommons.Models;

namespace Compass.WmsService.Domain.Entities;

public record StockOut : AggregateRootEntity
{
    public Guid CargoId { get; private set; }

    public Station_e Station { get;private set; }
    public string? OdpNumber { get;private set; }

    public double TransitQuantity { get;private set; }
    public double Quantity { get;private set; }
    public DateTime? ExpectedTime { get; private set; }
    public DateTime? OutTime { get;private set; }

    public Guid OperatorId { get; set; }//入库人
    public string? Remarks { get; private set; }


    private StockOut() { }
    public StockOut(Guid id, Guid cargoId, Station_e station, string? odpNumber, double transitQuantity, double quantity, DateTime? expectedTime, DateTime? outTime, Guid operatorId,string? remarks)
    {
        Id=id;
        CargoId=cargoId;
        
        Station=station;
        OdpNumber=odpNumber;

        TransitQuantity=transitQuantity;
        Quantity = quantity;
        ExpectedTime=expectedTime;
        OutTime = outTime;
        OperatorId=operatorId;
        Remarks=remarks;
    }

    public void Update(StockOutDto dto)
    {
        ChangeOdpNumber(dto.OdpNumber)
            .ChangeStation(dto.Station)
            .ChangeTransitQuantity(dto.TransitQuantity)
            .ChangeQuantity(dto.Quantity)
            .ChangeExpectedTime(dto.ExpectedTime)
            .ChangeOutTime(dto.OutTime)
            .ChangeRemarks(dto.Remarks);

        NotifyModified();
    }

    public StockOut ChangeStation(Station_e station)
    {
        Station=station;
        return this;
    }
    public StockOut ChangeOdpNumber(string? odpNumber)
    {
        OdpNumber=odpNumber;
        return this;
    }
    public StockOut ChangeTransitQuantity(double transitQuantity)
    {
        TransitQuantity=transitQuantity;
        return this;
    }
    public StockOut ChangeQuantity(double quantity)
    {
        Quantity=quantity;
        return this;
    }
    public StockOut ChangeExpectedTime(DateTime? expectedTime)
    {
        ExpectedTime=expectedTime;
        return this;
    }
    public StockOut ChangeOutTime(DateTime? outTime)
    {
        OutTime=outTime;
        return this;
    }
    public StockOut ChangeRemarks(string? remarks)
    {
        Remarks=remarks;
        return this;
    }
}